package sz.szsmk.citizencard.ui.fragment;

import android.app.DialogFragment;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chenenyu.router.Router;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.util.ACache;

/**
 * 展示注册电子市民卡的对话框
 */
public class CantCloseDialog extends DialogFragment {

    private View cancelView, actionLayout;

    private TextView elec_card_action_txt;

    private int action = 0;

    public CantCloseDialog() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getDialog().setCanceledOnTouchOutside(false);
        View view = inflater.inflate(R.layout.cant_close_dialog, container);
        cancelView = view.findViewById(R.id.dismiss_btn);
        elec_card_action_txt = (TextView) view.findViewById(R.id.elec_card_action_txt);
        actionLayout = view.findViewById(R.id.action_layout);
        return view;
    }

    public void setAction(int action) {
        this.action = action;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (action == 0) {
            elec_card_action_txt.setText("实名认证成功");
        } else {
            elec_card_action_txt.setText("实名认证成功");
        }
        cancelView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (action == 1) {

                    Router.build("firstrecharge").go(getActivity());
//                    AppendRealNameInfoActivity.instance.finish();
//                    BindCashCardActivity.instance.finish();
//                    SignUpElectronCardActivity.instance.finish();
                    dismiss();
                } else if (action == 0) {

                    Router.build("signupelectron").go(getActivity());
                    dismiss();
                }
                dismiss();
            }
        });
    }
}
